/**
 * @file    WebOleInPlaceFrame.cpp
 * @brief   
 * @date    2005-3-15 15:55:23
 * @author  GengYong (gengyong@gmail.com)
 *
 */

#include <cassert>
#include "WebOleInPlaceFrame.h"

using namespace xessage_private;

WebOleInPlaceFrame::WebOleInPlaceFrame(WebWindowImpl * app):m_appImpl(app),m_window(NULL), m_refCount(1)
{
	return;
}

WebOleInPlaceFrame::~WebOleInPlaceFrame()
{
	return;
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::QueryInterface(REFIID riid, LPVOID * ppvObject)
{
	if (ppvObject == NULL) return E_POINTER;

	if ((riid == IID_IUnknown) 
	 || (riid == IID_IOleInPlaceFrame))
	{
		this->AddRef();
		*ppvObject = this;
	}
	else
	{
		*ppvObject = 0;
		return(E_NOINTERFACE);
	}
	return S_OK;
}

ULONG STDMETHODCALLTYPE WebOleInPlaceFrame::AddRef()
{
	return InterlockedIncrement(&m_refCount);
}

ULONG STDMETHODCALLTYPE WebOleInPlaceFrame::Release()
{
	LONG result = InterlockedDecrement(&m_refCount);
	assert(result >= 0);
	if (result == 0)
	{
		delete this;
	}
	return (ULONG)(result);
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::GetWindow(HWND * lphwnd)
{
	return (lphwnd == NULL ? E_POINTER : (*lphwnd = this->m_window, S_OK));
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::ContextSensitiveHelp(BOOL fEnterMode)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::GetBorder(LPRECT lprectBorder)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::RequestBorderSpace(LPCBORDERWIDTHS pborderwidths)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::SetBorderSpace(LPCBORDERWIDTHS pborderwidths)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::SetActiveObject(IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
{
	return S_OK;
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::InsertMenus(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject)
{
	return S_OK;
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::RemoveMenus(HMENU hmenuShared)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::SetStatusText(LPCOLESTR pszStatusText)
{
	return S_OK;
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::EnableModeless(BOOL fEnable)
{
	return S_OK;
}

HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::TranslateAccelerator(LPMSG lpmsg, WORD wID)
{
	return E_NOTIMPL;;
}


HRESULT STDMETHODCALLTYPE WebOleInPlaceFrame::SetWindow(HWND hwnd)
{
	this->m_window = hwnd;
	return S_OK;
}
